package com.sc.nft.admin.controller;

import com.sc.nft.admin.request.EditConfigureTheMeltingModeReq;
import com.sc.nft.admin.request.IdRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.vo.AdminConfigureTheMeltingModeListVO;
import com.sc.nft.service.EcologyHatchMethodConfService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 配置方式控制层
 *
 * @Author：LiGen
 * @Package：com.sc.nft.admin.controller
 * @Project：sc_metago
 * @name：AdminEcologyHatchMethodConfController
 * @Date：2024/6/11 15:30
 * @Filename：AdminEcologyHatchMethodConfController
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/ecology/hatch/method")
@Api(tags = "后台配置方式管理")
public class AdminEcologyHatchMethodConfController {

    private final EcologyHatchMethodConfService ecologyHatchMethodConfService;

    @PostMapping(value = "/editConfigureTheMeltingMode", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增或者修改配置熔炼方式", notes = "新增生态熔炼配置", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result editConfigureTheMeltingMode(@Valid @RequestBody EditConfigureTheMeltingModeReq req) {
        ecologyHatchMethodConfService.editEcologyHatchMethodConf(req.getEcologyHatchId(), req.getConsumptionConsensus(), req.getConfigureTheMeltingModeVOList());
        return Result.success();
    }

    @PostMapping(value = "/AdminConfigureTheMeltingModeListVO", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "熔炼方式配置列表", notes = "熔炼方式配置列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<AdminConfigureTheMeltingModeListVO> getAdminConfigureTheMeltingModeListVO(@Valid @RequestBody IdRequest req) {
        return Result.success(ecologyHatchMethodConfService.getAdminConfigureTheMeltingModeListVO(req.getId()));
    }




}
